package com.cdu.service.impl;

import com.cdu.mapper.OrderMapper;
import com.cdu.pojo.entity.Order;
import com.cdu.pojo.entity.OrderItem;
import com.cdu.pojo.entity.User;
import com.cdu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.cdu.utils.OrderUtil.generateOrderNumber;

/**
 * @projectName: com.cdu.service.impl
 * @Author:jjj
 * @DateTime: 2024/12/18 下午8:25
 **/
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    /**
     * 创建订单
     * @param order
     * @param user
     */
    @Override
    public void createOrder(Order order, User user) {
        order.setUserId(user.getId());
        order.setStatus(0);
        order.setModifiedUser(user.getUsername());
        order.setIsDelete(0);
        order.setCreatedUser(user.getUsername());
        orderMapper.createOrder(order);
    }

    @Override
    public void createOrderItem(OrderItem orderItem, User user) {
        orderItem.setOrderId("123456");
        orderItem.setCreatedUser(user.getUsername());
        orderItem.setModifiedUser(user.getUsername());
        orderMapper.createOrderItem(orderItem);
    }
}
